package cn.usian.dispatch.parameter.controller;

import cn.usian.basicInformation.log.commons.Constants;
import cn.usian.basicInformation.log.commons.Log;
import cn.usian.dispatch.parameter.service.IDispatchService;
import cn.usian.pojo.Result;
import cn.usian.pojo.dispatch.DispatchParameters;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/parameter")
public class DispatchController {
    private static final Logger log = LoggerFactory.getLogger(DispatchController.class);
    @Autowired
    private IDispatchService dispatchService;

    @GetMapping("/list")
    public Result list(){
        log.info("测试");
        return Result.ok(dispatchService.list());
    }

    @PostMapping("/save")
    @Log(operationModule = "派单策略", operationType = Constants.UPDATE)
    public Result save(@RequestBody DispatchParameters dispatchParameters){
        String save = dispatchService.save(dispatchParameters);
        return Result.ok(save);
    }

    @GetMapping("/findById/{id}")
    public Result findById(@PathVariable("id") long id){
        return Result.ok(dispatchService.findById(id));
    }

}
